package com.bionic.banking.core.entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Date;

public class BankTransaction implements Serializable {

    private Integer txId;
    private String description;
    private Timestamp timeStamp;
    private Integer currencyId;
    private BigInteger amount;
    private BigInteger balance;
    private Integer txTypeId;
    private Integer accountId;
    private Integer targetAccountId;

    public BankTransaction() {
    }

    public BankTransaction(Integer txTypeId,Integer currencyCode,Integer accountId,
            BigInteger newBalance, BigInteger amount, String description) {
         this.txTypeId = txTypeId;
         this.currencyId= currencyCode;
         this.accountId= accountId;
         this.balance = newBalance;
         this.amount = amount;
         this.description = description;         
         Date currDate = new java.util.Date();
         Timestamp currDateTime = new Timestamp(currDate.getTime());         
         this.timeStamp =currDateTime;
    }

    public Integer getTxId() {
        return txId;
    }

    public void setTxId(Integer txId) {
        this.txId = txId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Timestamp getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Timestamp timeStamp) {
        this.timeStamp = timeStamp;
    }

    public int getCurrencyId() {
        return currencyId;
    }

    public void setCurrencyId(int currencyId) {
        this.currencyId = currencyId;
    }

    public BigInteger getAmount() {
        return amount;
    }

    public void setAmount(BigInteger amount) {
        this.amount = amount;
    }

    public BigInteger getBalance() {
        return balance;
    }

    public void setBalance(BigInteger balance) {
        this.balance = balance;
    }

    public Integer getTxTypeId() {
        return txTypeId;
    }

    public void setTxTypeId(Integer txTypeId) {
        this.txTypeId = txTypeId;
    }

    public Integer getAccountId() {
        return accountId;
    }

    public void setAccountId(Integer accountId) {
        this.accountId = accountId;
    }

    public Integer getTargetAccountId() {
        return targetAccountId;
    }

    public void setTargetAccountId(Integer targetAccountId) {
        this.targetAccountId = targetAccountId;
    }
    
    @Override
    public int hashCode() {

        int hash = 0;
        hash += (txId != null ? txId.hashCode() : 0);

        final int multiplier = 23;
        if (hash == 0) {
            int code = 133;            
            code = multiplier * code + txTypeId.hashCode();
            hash = code;
        }
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof BankTransaction)) {
            return false;
        }
        BankTransaction other = (BankTransaction) object;
        if ((this.txId == null && other.txId != null)
                || (this.txId != null && !this.txId.equals(other.txId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "transaction[ txId=" + txId + " ] " + description + ", amount: " + amount
                + " account " + accountId;
    }
}
